package assist.datastore.dao;

import java.util.Collection;

import assist.datastore.Datastore;

public class EntityDAO<T> extends AbstractDAO<T>
{
    private Datastore<T> datastore;
    protected EntityDAO(final Datastore<T> datastore, 
            final Class<T> domainClass)
    {
        super(domainClass);
        this.datastore = datastore;
    }
    public T save(T obj)
    {
        return this.datastore.save(obj);
    }
    
    public Collection<T> saveAll(final Collection<T> objects)
    {
        return this.datastore.saveAll(objects);
    }    

    public T getById(Object id)
    {
        return this.datastore.getById(this.getDomainClass(), id); 
    }
    
    /**
     * @return the underlying Datastore for this DAO, if needed.
     */
    protected Datastore<T> getDatastore()
    {
        return this.datastore;
    }    
}
